home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: bitmap.h,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:42 $
- */
- #ifndef __BITMAP_H__
- #define __BITMAP_H__
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
- /*
- * this structure is used to allocate bits from the bitmap
- */
- typedef struct {
-
- UFOUR bitOffset;
- UFOUR bitCount;
- UFOUR absoluteBitOffset;
- UFOUR word;
- SHORTPID page;
- GROUPLINK *groupLink;
-
- } BITCONTEXT;
-
-
- /*
- * define the maximum number of pages that can be allocated
- * at a single time. Right now this is calculated from
- * the maximum allocation of a single page. This MUST
- * be changed if we go to an extent allocation mechanism
- */
- #define MAX_ALLOC_PAGES (100)
-
-
- /*
- * define the maximum number of words that an allocated block can span
- */
- #define MAX_BIT_WORD_SPAN ((MAX_ALLOC_PAGES/BITSPERWORD) + 2)
-
-
- /*
- * this holds the context for a free run which may span pages
- */
- typedef struct {
-
- LISTELEMENT list;
- BITCONTEXT bitContext[MAX_BIT_WORD_SPAN];
- TWO contextIndex;
- MAGIC magic;
-
- } FREECONTEXT;
-
-
- /*
- * define the context magic number
- */
- #define FREECONTEXT_MAGIC 0xfad5134c
-
- /*
- * define magic number checks
- */
- #if MAGIC_CHECKING IS_ENABLED
-
-
- #define INIT_FREECONTEXT_MAGIC(_context) \
- _context->magic = FREECONTEXT_MAGIC;
-
-
- #define CHECK_FREECONTEXT_MAGIC(_context) \
- \
- if ((_context)->magic != FREECONTEXT_MAGIC) { \
- SM_ERROR(TYPE_FATAL, esmINTERNAL); \
- }
-
-
- #else
-
-
- #define INIT_FREECONTEXT_MAGIC(_context)
-
- #define CHECK_FREECONTEXT_MAGIC(_context)
-
-
- #endif
-
-
- /*
- * define a structure that holds a pid, grouplink and refcount
- */
- typedef struct {
-
- LISTELEMENT list;
- GROUPLINK *groupLink;
- PID pid;
- TWO fixCount;
- FOUR bitsChanged;
- MAGIC magic;
- } PAGECONTEXT;
-
-
- /*
- * define the context magic number
- */
- #define PAGECONTEXT_MAGIC 0x200a243c
-
- /*
- * define magic number checks
- */
- #if MAGIC_CHECKING IS_ENABLED
-
-
- #define INIT_PAGECONTEXT_MAGIC(_context) \
- _context->magic = PAGECONTEXT_MAGIC;
-
-
- #define CHECK_PAGECONTEXT_MAGIC(_context) \
- \
- if ((_context)->magic != PAGECONTEXT_MAGIC) { \
- SM_ERROR(TYPE_FATAL, esmINTERNAL); \
- }
-
-
- #else
-
-
- #define INIT_PAGECONTEXT_MAGIC(_context)
-
- #define CHECK_PAGECONTEXT_MAGIC(_context)
-
-
- #endif
-
-
- /*
- * define the number of pages in the bitmap page group
- */
- #define BITMAP_GROUP_SIZE 8
-
-
- /*
- * get the page given the bit
- * these are only applicable for bitmap routines
- * note that these depend on the bitmap usable
- * size being a multiple of 4 bytes
- */
- #define BIT_TO_PAGE(_bit) \
- (((ulong) (_bit)) / (BITMAP_USABLESIZE * 8))
-
-
- /*
- * get the bit offset in the page
- */
- #define BIT_IN_PAGE(_bit) \
- (((ulong) (_bit)) % (BITMAP_USABLESIZE * 8))
-
-
- /*
- * get the word offset given the bit
- */
- #define BIT_TO_WORD(_bit) \
- (((ulong) _bit) >> 5)
-
-
- /*
- * define the byte offset given the bit
- */
- #define BIT_TO_BYTE(_bit) \
- (((ulong) _bit) >> 3)
-
-
- /*
- * get the offset in the word given the bit
- */
- #define BIT_IN_WORD(_bit) \
- (_bit & 0x1f)
-
-
- /*
- * get the offset in the byte given the bit
- */
- #define BIT_IN_BYTE(_bit) \
- (_bit & 0x07)
-
-
- /*
- * define the offset to the given bits
- */
- #define PAGE_TO_BIT(_page) \
- (((ulong) _page) * (BITMAP_USABLESIZE * 8))
-
-
- /*
- * define the number of words in the page
- */
- #define WORDS_IN_PAGE (((ulong) BITMAP_USABLESIZE) / 4)
-
-
- /*
- * define the number of bits before the word
- */
- #define WORD_TO_BIT(_word) \
- (((ulong) _word) << 5)
-
-
- /*
- * define the number of words in the page
- */
- #define BITS_IN_PAGE (((ulong) BITMAP_USABLESIZE) * 8)
-
-
- /*
- * define a mask that gets the most significant bit
- */
- #define MSB_MASK 0x80000000
- #define ALLSET_MASK 0xffffffff
-
-
- /*
- * define the maximum number of pages that an allocated block can span
- */
- #define MAX_BIT_PAGE_SPAN(_allocBits) \
- (((_allocBits)/(BITMAP_USABLESIZE * 8)) + 2)
-
- #endif __BITMAP_H__
-